package com.hj.service.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.hj.domain.Courseinfo;
import com.hj.domain.Studentinfo;
import com.hj.exception.CustomException;
import com.hj.mapper.CourseinfoMapper;
import com.hj.service.inter.CourseServiceInter;

public class CourseServiceImp implements CourseServiceInter {

	@Autowired
	private CourseinfoMapper courseinfoMapper;
	@Override
	public List<Courseinfo> queryAllCourse() throws Exception {
		// TODO Auto-generated method stub
		List<Courseinfo> list=courseinfoMapper.queryAllCourse();  
		if(list.size()==0){
			throw  new CustomException("查询所有课程信息失败!");
		}
        return list; 
	}
	@Override
	public List<Courseinfo> searchCourseByTitle(String title) throws Exception {
		// TODO Auto-generated method stub
		List<Courseinfo> list=courseinfoMapper.searchCourseByTitle(title);  
		if(list.size()==0){
			throw  new CustomException("模糊查询课程信息失败!");
		}
        return list; 
	}
	@Override
	public boolean insertCourse(Courseinfo courseinfo) throws Exception {
		// TODO Auto-generated method stub
		boolean b=courseinfoMapper.insertCourse(courseinfo);
		if(b==false){
			throw  new CustomException("添加课程失败!");
		}
		return b;
	}
	@Override
	public boolean updateCourse(Courseinfo courseinfo) throws Exception {
		// TODO Auto-generated method stub
		boolean b=courseinfoMapper.updateCourse(courseinfo);
		if(b==false){
			throw  new CustomException("课程信息更新失败!");
		}
		return b;
	}

}
